package ac.il.technion.c236369.hw4.core.queues;

import org.apache.log4j.Logger;

import ac.il.technion.c236369.hw4.core.ServerRequest;
import ac.il.technion.c236369.hw4.core.queues.exception.NotEnoughtPlaceInQueue;

public class InsertRequestQueue implements Runnable {

	private ServerRequest request = null;
	private final Logger log = Logger.getLogger(InsertRequestQueue.class);
	public InsertRequestQueue( final ServerRequest request) {
		this.request  = request;
	}

	@Override
	public void run() {
		while( true) {
			try {
				ServerRequestsQueue.getInstance().add( request);
			} catch (NotEnoughtPlaceInQueue e) {
				try {
					Thread.sleep(500);
				} catch (InterruptedException e1) {
					log.error(e);
				}
			}
		}

	}

}
